09. Clustering with PCL

Clustering with PCL

Now it's time to jump back into ROS, Gazebo and Rviz to do some clustering segmentation on your point clouds! In this exercise, you'll use a PCL library function called EuclideanClusterExtraction() to perform a DBSCAN cluster search on your 3D point cloud.

If you already cloned the RoboND-Perception-Exercises repository then you're all setup with what you need to complete this next exercise. Otherwise go ahead and clone the repository now to get started.

In this exercise, you'll be working with the same tabletop scene from the last lesson, but now visualizing the scene using ROS and Gazebo. Assuming you already have a Catkin workspace setup on your virtual machine (or locally) the first step is to copy or move the /sensor_stick directory and all of its contents to ~/catkin_ws/src.

$ cp -r ~/RoboND-Perception-Exercises/Exercise-2/sensor_stick ~/catkin_ws/src/

Next, use rosdep to grab all the dependencies you need to run this exercise.

$ cd ~/catkin_ws
$ rosdep install --from-paths src --ignore-src --rosdistro=kinetic -y

After that, run catkin_make to build the dependencies.

$ catkin_make

Add the following lines to your .bashrc file

export GAZEBO_MODEL_PATH=~/catkin_ws/src/sensor_stick/models
source ~/catkin_ws/devel/setup.bash

Now, you should be all setup to launch the environment! Run the following command to launch the scene in Gazebo and RViz:

$ roslaunch sensor_stick robot_spawn.launch

Your RViz window should look like this:

The scene in the lower left is the view as seen from an RGB-D camera mounted on top of the blue stick robot you see in the scene, hence the name "sensor_stick" for the exercise. If you don't see the exact image above when you launch the environment, you can change the "Style" of your PointCloud2 data from "Points" to "Flat Squares" as shown below.

Next, you'll write a ROS node to publish the point cloud as seen from the camera on the sensor stick!